﻿	      <?php include("conn.php");
             mysql_query('SET NAMES UTF8'); 

	  

class MyPrizeBean
{
	public $images;
	public $shopid;
	public $title;
	public $distance;
	public $evaluate;
	public $reply;
	public $like;
	public $cid;
	
	function __construct($images,$shopid,$title,$distance,$evaluate,$reply,$like,$cid)
	{
		
		$this->images      = $images;
		$this->shopid      = $shopid;
		$this->title      = $title;
		$this->distance      = $distance;
		$this->evaluate      = $evaluate;
		$this->reply      = $reply;
		$this->like      = $like;
		$this->cid      = $cid;
	
	}
}

if($_REQUEST['page']!="")
{
$de=$_REQUEST['page']*$_REQUEST['pagesize'];
$size=$_REQUEST['pagesize'];
}

else
{
$de=0;
$size=5;
}


	$uid=2;
	$state=1;
	$dates="";
	$prize = array();
	$rert30=mysql_query("select *from collect where userid='".$_REQUEST[userid]."'and shopid !='".$dates."'order by id desc limit $de,$size");
	while($rowf=mysql_fetch_array($rert30)){
	
	 $rert31=mysql_query("select *from shop where shopid ='".$rowf[shopid]."' ");
$rowf1=mysql_fetch_array($rert31);


$counts=mysql_query("select SUM(service) from goodsreply  where   shopid ='".$rowf['shopid']."'");

//评论数
$rss=mysql_fetch_array($counts);
$sum=$rss[0];



$count=mysql_query("select count(*) from goodsreply  where   shopid ='".$rowf['shopid']."'");

//评论数
$rs=mysql_fetch_array($count);
$totalNumber=$rs[0];


$countd=mysql_query("select count(*) from likes  where   shopid ='".$rowf['shopid']."'");

//点赞数
$rsd=mysql_fetch_array($countd);
$totalNumber1=$rsd[0];
if($totalNumber1==0 or $totalNumber1=="")
{
$shu=0;
}
else
{
$shu=$totalNumber1;
}
if($totalNumber!=0)
{
$sum=$totalNumber;
$ping=round(($sum/$totalNumber),2);
}
else
{
$ping=5;

}

if ($ping < 2) {
                            $pinfen = "<span></span><span class='empty'></span><span class='empty'></span><span class='empty'></span><span class='empty'></span>";
                        } 
						
						 else if ($ping < 3 and $ping > 2) {
                            $pinfen = "<span></span><span></span><span class='empty'></span><span class='empty'></span><span class='empty'></span>";
                        } 
						
						 else if ($ping < 4 and $ping > 3) {
                           $pinfen = "<span></span><span></span><span ></span><span class='empty'></span><span class='empty'></span>";
                        }
						 else if ($ping < 5 and $ping > 4) {
                           $pinfen = "<span></span><span></span><span ></span><span></span><span class='empty'></span>";
                        }
						 else  {
                           $pinfen = "<span></span><span></span><span ></span><span ></span><span ></span>";
                        }
   $juli=0.12;
			$prize[] = new MyPrizeBean($rowf1['images'],$rowf1['shopid'],$rowf1['name'],$juli,$pinfen,$totalNumber,$shu,$rowf['id']);
		
	}

echo json_encode($prize);


?>